<?php
header("Content-Type:text/html;charset=utf-8");
date_default_timezone_set('PRC'); //设置中国时区 

$controller = 'Category';



$path = dirname(__FILE__);

$controller_str = file_get_contents($path.'/template/Controller.php');
$model_str = file_get_contents($path.'/template/Model.php');
$index_str = file_get_contents($path.'/template/vuejs/index.vue');

$data = array(
	'controller' => $controller,
	'date' => date('Y/m/d'),
	'time' => date('H:i')
);

$controller_str = tihuan($controller_str,$data);
file_put_contents($path.'/news/'.$controller.'Controller.php',$controller_str);

$model_str = tihuan($model_str,$data);
file_put_contents($path.'/news/'.$controller.'.php',$model_str);

$index_str = tihuan($index_str,$data);
file_put_contents($path.'/news/'.$controller.'/index.vue',$index_str);


function tihuan($str,$data)
{
	foreach($data as $key => $v){
		$k = '{$'.$key.'}';
		$str = str_replace($k,$v,$str);
	}
	return $str;
}